﻿using System;
using SAS.Bussiness.Enum;
using SAS.WebSite.BaseClasses;


namespace EDD.WEB.VisualControls.Nav
{
    public partial class Main : BaseUserControl
    {
        //private Navigation MainNav;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            BuildNavigation();
        }

        protected void BuildNavigation()
        {

            BasePage basePage = Page as BasePage;
            if(basePage != null)
            {
                if(String.CompareOrdinal(basePage.User.ClientRoleName, Permission.WorkspaceAdmin) == 0)
                {
                    billingConsuption.Attributes["class"] = "navdis";
                    billingConsuption.Attributes.Remove("href");

                    billingCreadit.Attributes["class"] = "navdis";
                    billingCreadit.Attributes.Remove("href");
                    
                    billingItem.Attributes["class"] = "navdis";
                    billingItem.Attributes.Remove("href");

                    billingPurchase.Attributes["class"] = "navdis";
                    billingPurchase.Attributes.Remove("href");

                    userTab.Attributes["class"] = "navdis";
                    userTab.Attributes.Remove("href");
                    return;
                }
                if (String.CompareOrdinal(basePage.User.ClientRoleName, Permission.BillingAdmin) == 0)
                {
                    workspaceTab.Attributes["class"] = "navdis";
                    workspaceTab.Attributes.Remove("href");

                    userTab.Attributes["class"] = "navdis";
                    userTab.Attributes.Remove("href");
                    return;
                }
            }

            //Navigation FullNav = ((BasePage)Page).SiteNavigation;
            //NavigationItem CurrentNav = ((BasePage)Page).CurrentNavItem;
            //if (CurrentNav == null)
            //{
            //    CurrentNav = new NavigationItem();
            //}
            //MainNav = new Navigation();
            //MainNav.Items = FullNav.Items.Where(x => x.Type == (int)NavType.main).ToList();
            //if (MainNav != null)
            //{
            //    int itemrow = 0;
            //    StringBuilder sb = new StringBuilder();
            //    sb.Append("<ul id=\"navigation\">");
            //    foreach (NavigationItem item in MainNav.Items)
            //    {
            //        sb.Append("<li id=\"nav");
            //        sb.Append(itemrow);
            //        sb.Append("\"><a href=\"");
            //        if ((item.Url == "#")||(item.HasPermission == 0))
            //        {
            //            sb.Append("#\" class=\"navdis\"><span class=\"navspan\">");
            //        }
            //        else if ((item.Url == CurrentNav.Url) || (item.Url == CurrentNav.ParentUrl))
            //        {
            //            sb.Append(item.Url);
            //            sb.Append("\" class=\"navon\" onClick=\"clearSid();\"><span class=\"navspanon\">");
            //        }
            //        else{
            //            sb.Append(item.Url);
            //            sb.Append("\" class=\"navoff\" onClick=\"clearSid();\"><span class=\"navspan\">");
            //        }
            //        if (item.Name == "Home")
            //        {
            //            sb.Append("<div id=\"buttonHomewrapper\"><div id=\"buttonHomelink\"></div></div>");  //src=\"../images/icon_home.png\" border=\"0\" width=\"14px\" height=\"13px\"/>
            //        }
            //        else
            //        {
            //            sb.Append(item.Name);
            //        }
            //        sb.Append("</span></a></li>");
            //        sb.Append("<li class=\"divider\"><img src=\"../../images/nav_divider.png\"/></li>");
            //        itemrow++;
            //    }
            //    sb.Append("</ul>");
            //    litNav.Text = sb.ToString();
            //}
        }

    }
}